<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>添加用户</h1>
    <span>用户名:</span>
    <input type="text" name="username">
    <br>
    <span>密码:</span>
    <input type="password" name="password">
    <br>
    <button>提交</button>
    <script src="./node_modules/axios/dist/axios.js"></script>
    <script>
        const btn = document.querySelector("button");
        const url = "http://localhost:3000/users";
        btn.addEventListener("click",()=>{
            const username = document.querySelector('input[type="text"]').value;
            const psw = document.querySelector('input[type="password"]').value;
            axios({
                method:"post",
                url:url,
                data:{username:username,password:psw},
            }).then((res)=>{
                location.href = "./index.html";
            });
            
        })
    </script>
</body>
</html>